package com.leetcode;

public class leetcode50 {
    public static void main(String[] args) {
        Solution solution = new Solution();
        double ans = solution.myPow(2.000000, 10);
        System.out.println(ans);
    }
    static class Solution {
        public double myPow(double x, int n) {
            double sum = 1.0;
            if(n < 0){
                x = 1/x;
                n = -n;
            }
            while(n > 0){
                if((n&1) == 1){
                    sum *= x;
                }
                x *= x;
                n >>>= 1;
            }
            return sum;
        }

    }
}
